﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;

namespace WebSite.admin.product
{
    public partial class goods_type_add : System.Web.UI.Page
    {
        // Fields

        // Methods
        protected void Button1_Click(object sender, EventArgs e)
        {
            upload upload = new upload();
            string str = upload.Up(this.file1, "../../uploadfile/");
            base.Response.Write(upload.Resup[Convert.ToInt32(str)]);
            this.pic.Text = upload.s;
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            SQLAccess.DoSql("update [DB_Shuxintype] set pic='" + this.pic.Text + "' where shuxinid=" + base.Request.QueryString["sid"] + "");
            base.Response.Write("<script language='javascript'>alert('更新成功');window.location.href='goods_type.aspx';</script>");
            base.Response.End();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Session["Adminlogin"] == null)
            {
                base.Response.Write("<script language=javascript>window.top.location.href='../login.aspx';</script>");
                base.Response.End();
            }
            if (!base.IsPostBack && (base.Request.QueryString["sid"] != null))
            {
                this.upbind();
            }
        }

        private void upbind()
        {
            DataTable table = SQLAccess.GreatDs("select * from DB_Shuxintype where shuxinid=" + base.Request.QueryString["sid"] + "").Tables[0];
            if (table.Rows.Count > 0)
            {
                this.pic.Text = table.Rows[0]["pic"].ToString();
            }
        }

        // Properties
        protected global_asax ApplicationInstance
        {
            get
            {
                return (global_asax)this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }

    }
}